#pragma once
#include"HashTable.h"
namespace bao
{
	template<class K,class V, class Hash = HashFunc<K>>
	class unordered_map
	{
	public:
		struct KeyOfT_unordered_map
		{
			const K& operator()(const pair<K,V>& kv)
			{
				return kv.first;
			}
		};
		typedef typename HashTable<K, pair<const K, V>, KeyOfT_unordered_map, Hash>::Itetator iterator;
		typedef typename HashTable<K, pair<const K, V>, KeyOfT_unordered_map, Hash>::Const_Itetator const_iterator;
		iterator begin()
		{
			return _hst.Begin();
		}
		iterator end()
		{
			return _hst.End();
		}
		const_iterator begin() const
		{
			return _hst.Begin();
		}
		const_iterator end() const
		{
			return _hst.End();
		}
		pair<iterator,bool> insert(const pair<K, V>& kv)
		{
			return _hst.Insert(kv);
		}
		iterator find(const K& key)
		{
			return _hst.Find(key);
		}
		bool erase(const K& key)
		{
			return _hst.Erase(key);
		}
		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = insert({key,V()});
			return ret.first->second;
		}
	private:
		HashTable<K, pair<const K,V>, KeyOfT_unordered_map, Hash> _hst;
	};
}
